<!--
Copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
-->
<!-- boost-no-inspect -->
<!-- HTML header for doxygen 1.8.9.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<title>Boost.Hana: Applicative</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
// Copyright Louis Dionne 2013-2017
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
MathJax.Hub.Config({
    "HTML-CSS": {
        linebreaks: {
            automatic: true,
            width: "75% container"
        }
    }
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<!-- Additional javascript for drawing charts. -->
<script type="text/javascript" src="highcharts.js"></script>
<script type="text/javascript" src="highcharts-data.js"></script>
<script type="text/javascript" src="highcharts-exporting.js"></script>
<script type="text/javascript" src="chart.js"></script>
<script type="text/javascript" src="hana.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Boost.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">Boost.Hana
   &#160;<span id="projectnumber">1.7.1</span>
   </div>
   <div id="projectbrief">Your standard library for metaprogramming</div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('group__group-_applicative.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">Applicative<div class="ingroups"><a class="el" href="group__group-concepts.html">Concepts</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
<p>The <code>Applicative</code> concept represents <code>Functor</code>s with the ability to lift values and combine computations. </p>
<p>A <code>Functor</code> can only take a normal function and map it over a structure containing values to obtain a new structure containing values. Intuitively, an <code>Applicative</code> can also take a value and lift it into the structure. In addition, an <code>Applicative</code> can take a structure containing functions and apply it to a structure containing values to obtain a new structure containing values. By currying the function(s) inside the structure, it is then also possible to apply n-ary functions to n structures containing values.</p>
<dl class="section note"><dt>Note</dt><dd>This documentation does not go into much details about the nature of applicatives. However, the <a href="https://wiki.haskell.org/Typeclassopedia#Applicative">Typeclassopedia</a> is a nice Haskell-oriented resource where such information can be found.</dd></dl>
<h2><a class="anchor" id="autotoc_md72"></a>
Minimal complete definition</h2>
<p><code>lift</code> and <code>ap</code> satisfying the laws below. An <code>Applicative</code> must also be a <code>Functor</code>.</p>
<h2><a class="anchor" id="autotoc_md73"></a>
Laws</h2>
<p>Given an <code>Applicative</code> <code>F</code>, the following laws must be satisfied:</p><ol type="1">
<li>Identity<br  />
For all objects <code>xs</code> of tag <code>F(A)</code>, <div class="fragment"><div class="line">ap(lift&lt;F&gt;(<span class="keywordtype">id</span>), xs) == xs</div>
</div><!-- fragment --></li>
<li>Composition<br  />
For all objects <code>xs</code> of tag <code>F(A)</code> and functions-in-an-applicative \( fs : F(B \to C) \), \( gs : F(A \to B) \), <div class="fragment"><div class="line">ap(ap(lift&lt;F&gt;(<a class="code" href="group__group-functional.html#ga3b16146e53efcdf9ecbb9a7b21f8cd0b">compose</a>), fs, gs), xs) == ap(fs, ap(gs, xs))</div>
<div class="ttc" id="agroup__group-functional_html_ga3b16146e53efcdf9ecbb9a7b21f8cd0b"><div class="ttname"><a href="group__group-functional.html#ga3b16146e53efcdf9ecbb9a7b21f8cd0b">boost::hana::compose</a></div><div class="ttdeci">constexpr auto compose</div><div class="ttdoc">Return the composition of two functions or more.</div><div class="ttdef"><b>Definition:</b> compose.hpp:52</div></div>
</div><!-- fragment --></li>
<li>Homomorphism<br  />
For all objects <code>x</code> of tag <code>A</code> and functions \( f : A \to B \), <div class="fragment"><div class="line">ap(lift&lt;F&gt;(f), lift&lt;F&gt;(x)) == lift&lt;F&gt;(f(x))</div>
</div><!-- fragment --></li>
<li>Interchange<br  />
For all objects <code>x</code> of tag <code>A</code> and functions-in-an-applicative \( fs : F(A \to B) \), <div class="fragment"><div class="line">ap(fs, lift&lt;F&gt;(x)) == ap(lift&lt;F&gt;(<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>(-, x)), fs)</div>
<div class="ttc" id="agroup__group-functional_html_ga30027c383676084be151ef3c6cf2829f"><div class="ttname"><a href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">boost::hana::apply</a></div><div class="ttdeci">constexpr auto apply</div><div class="ttdoc">Invokes a Callable with the given arguments.</div><div class="ttdef"><b>Definition:</b> apply.hpp:40</div></div>
</div><!-- fragment --> where <code>apply(-, x)</code> denotes the partial application of the <code>apply</code> function from the <a class="el" href="group__group-functional.html">Functional</a> module to the <code>x</code> argument.</li>
</ol>
<p>As a consequence of these laws, the model of <code>Functor</code> for <code>F</code> will satisfy the following for all objects <code>xs</code> of tag <code>F(A)</code> and functions \( f : A \to B \): </p><div class="fragment"><div class="line">transform(xs, f) == ap(lift&lt;F&gt;(f), xs)</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md74"></a>
Refined concept</h2>
<ol type="1">
<li><code>Functor</code> (free model)<br  />
As a consequence of the laws, any <code>Applicative F</code> can be made a <code>Functor</code> by setting <div class="fragment"><div class="line">transform(xs, f) = ap(lift&lt;F&gt;(f), xs)</div>
</div><!-- fragment --></li>
</ol>
<h2><a class="anchor" id="autotoc_md75"></a>
Concrete models</h2>
<p><code><a class="el" href="structboost_1_1hana_1_1lazy.html" title="hana::lazy implements superficial laziness via a monadic interface.">hana::lazy</a></code>, <code><a class="el" href="structboost_1_1hana_1_1optional.html" title="Optional value whose optional-ness is known at compile-time.">hana::optional</a></code>, <code><a class="el" href="structboost_1_1hana_1_1tuple.html" title="General purpose index-based heterogeneous sequence with a fixed length.">hana::tuple</a></code></p>
<p><a class="anchor" id="applicative-transformation"></a></p>
<h2><a class="anchor" id="autotoc_md76"></a>
Structure-preserving functions</h2>
<p>An <em>applicative transformation</em> is a function \( t : F(X) \to G(X) \) between two Applicatives <code>F</code> and <code>G</code>, where <code>X</code> can be any tag, and which preserves the operations of an Applicative. In other words, for all objects <code>x</code> of tag <code>X</code>, functions-in-an-applicative \( fs : F(X \to Y) \) and objects <code>xs</code> of tag <code>F(X)</code>, </p><div class="fragment"><div class="line">t(lift&lt;F&gt;(x)) == lift&lt;G&gt;(x)</div>
<div class="line">t(ap(fs, xs)) == ap(t(fs), t(xs))</div>
</div><!-- fragment --> <table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga4b7188568b24c715ec8e43595de6844d"><td class="memItemLeft" align="right" valign="top">times&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_applicative.html#ga4b7188568b24c715ec8e43595de6844d">boost::hana::A</a> (T_1) \times \cdots \times A(T_n) \<a class="el" href="group__group-core.html#gadc70755c1d059139297814fb3bfeb91e">to</a> A(U) @f$. const expr auto ap</td></tr>
<tr class="memdesc:ga4b7188568b24c715ec8e43595de6844d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Lifted application.  <a href="group__group-_applicative.html#ga4b7188568b24c715ec8e43595de6844d">More...</a><br /></td></tr>
<tr class="separator:ga4b7188568b24c715ec8e43595de6844d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:ga712038d7abbc7159f8792788f7cd0c73"><td class="memTemplParams" colspan="2">template&lt;typename A &gt; </td></tr>
<tr class="memitem:ga712038d7abbc7159f8792788f7cd0c73"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__group-_applicative.html#ga712038d7abbc7159f8792788f7cd0c73">boost::hana::lift</a></td></tr>
<tr class="memdesc:ga712038d7abbc7159f8792788f7cd0c73"><td class="mdescLeft">&#160;</td><td class="mdescRight">Lift a value into an <code>Applicative</code> structure.  <a href="group__group-_applicative.html#ga712038d7abbc7159f8792788f7cd0c73">More...</a><br /></td></tr>
<tr class="separator:ga712038d7abbc7159f8792788f7cd0c73"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga4b7188568b24c715ec8e43595de6844d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4b7188568b24c715ec8e43595de6844d">&#9670;&nbsp;</a></span>A()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">times boost::hana::A </td>
          <td>(</td>
          <td class="paramtype">T_1&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2ap_8hpp.html">boost/hana/fwd/ap.hpp</a>&gt;</code></p>

<p>Lifted application. </p>
<p>Specifically, <code>ap</code> applies a structure containing functions to a structure containing values, and returns a new structure containing values. The exact way in which the functions are applied to the values depends on the <code>Applicative</code>.</p>
<p><code>ap</code> can be called with two arguments or more; the functions in the <code>f</code> structure are curried and then applied to the values in each <code>x...</code> structure using the binary form of <code>ap</code>. Note that this requires the number of <code>x...</code> must match the arity of the functions in the <code>f</code> structure. In other words, <code>ap(f, x1, ..., xN)</code> is equivalent to </p><div class="fragment"><div class="line">((<a class="code" href="group__group-functional.html#ga49ea872ade5ac8f6c10052c495302e89">curry</a>(f) ap x1) ap x2) ... ap xN</div>
<div class="ttc" id="agroup__group-functional_html_ga49ea872ade5ac8f6c10052c495302e89"><div class="ttname"><a href="group__group-functional.html#ga49ea872ade5ac8f6c10052c495302e89">boost::hana::curry</a></div><div class="ttdeci">constexpr auto curry</div><div class="ttdoc">Curry a function up to the given number of arguments.</div><div class="ttdef"><b>Definition:</b> curry.hpp:88</div></div>
</div><!-- fragment --><p> where <code>x ap y</code> is just <code>ap(x, y)</code> written in infix notation to emphasize the left associativity.</p>
<h2><a class="anchor" id="autotoc_md55"></a>
Signature</h2>
<p>Given an Applicative <code>A</code>, the signature is </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">f</td><td>A structure containing function(s).</td></tr>
    <tr><td class="paramname">x...</td><td>Structure(s) containing value(s) and on which <code>f</code> is applied. The number of structures must match the arity of the functions in the <code>f</code> structure.</td></tr>
  </table>
  </dd>
</dl>
<h2><a class="anchor" id="autotoc_md56"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="ap_8hpp.html">boost/hana/ap.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="config_8hpp.html">boost/hana/config.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="tuple_8hpp.html">boost/hana/tuple.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;functional&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    <span class="comment">// with tuples</span></div>
<div class="line">    static_assert(</div>
<div class="line">        hana::ap(hana::make_tuple(std::plus&lt;&gt;{}), hana::make_tuple(1, 2),</div>
<div class="line">                                                  hana::make_tuple(3, 4, 5))</div>
<div class="line">            ==</div>
<div class="line">        hana::make_tuple(</div>
<div class="line">            1 + 3,      1 + 4,      1 + 5,</div>
<div class="line">            2 + 3,      2 + 4,      2 + 5</div>
<div class="line">        )</div>
<div class="line">    , <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// with optional values</span></div>
<div class="line">    BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> multiply = [](<span class="keyword">auto</span> a, <span class="keyword">auto</span> b, <span class="keyword">auto</span> c) {</div>
<div class="line">        <span class="keywordflow">return</span> a * b * c;</div>
<div class="line">    };</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a>(</div>
<div class="line">        hana::ap(hana::just(multiply), hana::just(1),</div>
<div class="line">                                       hana::just(2),</div>
<div class="line">                                       hana::just(3))</div>
<div class="line">            ==</div>
<div class="line">        hana::just(1 * 2 * 3)</div>
<div class="line">    );</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(</div>
<div class="line">        hana::ap(hana::just(multiply), hana::just(1),</div>
<div class="line">                                       hana::nothing,</div>
<div class="line">                                       hana::just(3))</div>
<div class="line">            ==</div>
<div class="line">        hana::nothing</div>
<div class="line">    );</div>
<div class="line">}</div>
<div class="ttc" id="aap_8hpp_html"><div class="ttname"><a href="ap_8hpp.html">ap.hpp</a></div><div class="ttdoc">Defines boost::hana::ap.</div></div>
<div class="ttc" id="aassert_8hpp_html"><div class="ttname"><a href="assert_8hpp.html">assert.hpp</a></div><div class="ttdoc">Defines macros to perform different kinds of assertions.</div></div>
<div class="ttc" id="aconfig_8hpp_html"><div class="ttname"><a href="config_8hpp.html">config.hpp</a></div><div class="ttdoc">Defines configuration macros used throughout the library.</div></div>
<div class="ttc" id="aequal_8hpp_html"><div class="ttname"><a href="equal_8hpp.html">equal.hpp</a></div><div class="ttdoc">Defines boost::hana::equal.</div></div>
<div class="ttc" id="agroup__group-assertions_html_ga2c5006540936d9f8880e3a39f4fcc035"><div class="ttname"><a href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a></div><div class="ttdeci">#define BOOST_HANA_CONSTANT_CHECK(...)</div><div class="ttdoc">Equivalent to BOOST_HANA_CONSTANT_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERTI...</div><div class="ttdef"><b>Definition:</b> assert.hpp:239</div></div>
<div class="ttc" id="agroup__group-assertions_html_gac7aafc41e4dcc7d1f1929fb00f010d2a"><div class="ttname"><a href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a></div><div class="ttdeci">#define BOOST_HANA_CONSTEXPR_CHECK(...)</div><div class="ttdoc">Equivalent to BOOST_HANA_CONSTEXPR_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERT...</div><div class="ttdef"><b>Definition:</b> assert.hpp:300</div></div>
<div class="ttc" id="anamespaceboost_1_1hana_html"><div class="ttname"><a href="namespaceboost_1_1hana.html">boost::hana</a></div><div class="ttdoc">Namespace containing everything in the library.</div><div class="ttdef"><b>Definition:</b> accessors.hpp:20</div></div>
<div class="ttc" id="aoptional_8hpp_html"><div class="ttname"><a href="optional_8hpp.html">optional.hpp</a></div><div class="ttdoc">Defines boost::hana::optional.</div></div>
<div class="ttc" id="atuple_8hpp_html"><div class="ttname"><a href="tuple_8hpp.html">tuple.hpp</a></div><div class="ttdoc">Defines boost::hana::tuple.</div></div>
</div><!-- fragment --><dl class="todo"><dt><b><a class="el" href="todo.html#_todo000004">Todo:</a></b></dt><dd>Consider giving access to all the arguments to the tag-dispatched implementation for performance purposes. </dd></dl>

</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
<a id="ga712038d7abbc7159f8792788f7cd0c73"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga712038d7abbc7159f8792788f7cd0c73">&#9670;&nbsp;</a></span>lift</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename A &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto boost::hana::lift</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">constexpr</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2lift_8hpp.html">boost/hana/fwd/lift.hpp</a>&gt;</code></p>
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x) {</div>
<div class="line">        <span class="keywordflow">return</span> tag-dispatched;</div>
<div class="line">    }</div>
</div><!-- fragment -->
<p>Lift a value into an <code>Applicative</code> structure. </p>
<p><code>lift&lt;A&gt;</code> takes a normal value and embeds it into a structure whose shape is represented by the <code>A</code> <code>Applicative</code>. Note that the value may be a function, in which case the created structure may be <code>ap</code>plied to another <code>Applicative</code> structure containing values.</p>
<h2><a class="anchor" id="autotoc_md259"></a>
Signature</h2>
<p>Given an Applicative <code>A</code>, the signature is \( \mathtt{lift}_A : T \to A(T) \).</p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">A</td><td>A tag representing the <code>Applicative</code> into which the value is lifted.</td></tr>
  </table>
  </dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">x</td><td>The value to lift into the applicative.</td></tr>
  </table>
  </dd>
</dl>
<h2><a class="anchor" id="autotoc_md260"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="lift_8hpp.html">boost/hana/lift.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="tuple_8hpp.html">boost/hana/tuple.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">static_assert(hana::lift&lt;hana::tuple_tag&gt;(<span class="charliteral">&#39;x&#39;</span>) == hana::make_tuple(<span class="charliteral">&#39;x&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">static_assert(hana::lift&lt;hana::optional_tag&gt;(<span class="charliteral">&#39;x&#39;</span>) == hana::just(<span class="charliteral">&#39;x&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
<div class="ttc" id="alift_8hpp_html"><div class="ttname"><a href="lift_8hpp.html">lift.hpp</a></div><div class="ttdoc">Defines boost::hana::lift.</div></div>
</div><!-- fragment --> 
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!--
Copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
-->
<!-- boost-no-inspect -->
<!-- HTML footer for doxygen 1.8.9.1-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
  </ul>
</div>
</body>
</html>
